<template>
  <div class="monitor_item">
    <div class="item_title flex-x">
      <img
        src="@/assets/images/shebeiIcon/msg_7.png"
        style="width: 11px; height: 11px; margin-right: 4px"
        alt=""
      />
      <div class="title_text">设备利用率</div>
    </div>
    <div class="chart w100 h-full" ref="chart"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      lineChart: null,
      radio1: "日",
    };
  },
  mounted() {
    setTimeout(() => {
      this.init();
    }, 1000);
  },
  methods: {
    init() {
      const option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            lineStyle: {
              color: "#fff",
            },
          },
        },
        grid: {
          top: "10%",
          left: "3%",
          right: "4%",
          bottom: "25%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            axisLabel: {
              textStyle: {
                color: "#fff",
              },
            },

            axisLine: {
              show: true,
              lineStyle: {
                color: "#01134F",
                type: "solid",
              },
            },
            data: [
              "13:00",
              "13:05",
              "13:10",
              "13:15",
              "13:20",
              "13:25",
              "13:30",
              "13:35",
              "13:40",
              "13:45",
              "13:50",
              "13:55",
            ],
          },
        ],
        yAxis: [
          {
            type: "value",
            axisTick: {
              show: false,
            },
            axisLine: {
              lineStyle: {
                color: "#fff",
              },
            },
            axisLabel: {
              margin: 10,
              textStyle: {
                fontSize: 12,
              },
            },
            splitLine: {
              lineStyle: {
                color: "#01134F",
              },
            },
          },
        ],
        series: [
          {
            name: "设备利用率",
            type: "line",
            smooth: true,
            symbol: "circle",
            symbolSize: 5,
            showSymbol: false,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(0,252,255, 0.3)",
                    },
                    {
                      offset: 0.8,
                      color: "rgba(0,252,255, 0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(0, 0, 0, 0.1)",
                shadowBlur: 10,
              },
            },
            itemStyle: {
              normal: {
                color: "rgb(0,252,255)",
                borderColor: "rgba(137,189,2,0.27)",
                borderWidth: 12,
              },
            },
            data: [220, 182, 125, 145, 122, 191, 134, 150, 120, 110, 165, 122],
          },
        ],
      };

      this.$nextTick(() => {
        if (!this.lineChart) {
          this.lineChart = this.$echarts.init(this.$refs.chart);
        }
        this.lineChart.setOption(option);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.monitor_item {
  margin-top: 20px;
  .item_title {
    width: 100%;
    height: 26px;
    background: linear-gradient(-90deg, #000949, #1c349a);
    padding-left: 10px;
    border-radius: 5px;
    .title_text {
      color: #fff;
      font-size: 14px;
    }
  }
}
</style>